package cn.ynu.cmrs.asyncTask;

import android.app.Activity;
import android.os.AsyncTask;
import android.view.View;
import android.widget.Toast;

/**
 * A abstract class, get informations form server
 * 
 * @author starsfury
 * 
 */
public abstract class GetInfosTask<Input, Result> extends
		AsyncTask<Input, View, Result> {

	protected Activity mActivity;
	protected int mFailMsg;
	protected View mView;

	public GetInfosTask(Activity mActivity, int mFailMsg, View mView) {
		super();
		this.mActivity = mActivity;
		this.mFailMsg = mFailMsg;
		this.mView = mView;
	}

	/**
	 * Show fail messages
	 * 
	 * @param msg
	 */
	protected void failMsg(String msg) {
		Toast.makeText(mActivity, mActivity.getString(mFailMsg) + msg,
				Toast.LENGTH_LONG).show();
	}

	/**
	 * Very abstract function, executed when result is expected
	 * 
	 * @param result
	 * @return
	 */
	protected abstract void doStuffWithResult(Result result);

}
